const fs = require('fs')
const path = require('path')
const { execSync } = require('child_process')

module.exports = async function (context) {
  const sandboxPath = path.join(context.appOutDir, 'chrome-sandbox')
  if (fs.existsSync(sandboxPath)) {
    try {
      // 设置 root 所有权
      execSync(`sudo chown root:root ${sandboxPath}`)
      // 设置 SUID 权限
      execSync(`sudo chmod 4755 ${sandboxPath}`)
      console.log('  • Successfully set sandbox permissions.')
    } catch (error) {
      console.error('  • Error setting sandbox permissions:', error)
    }
  } else {
    console.error('  • chrome-sandbox not found!')
  }
}
